import React, { Component } from 'react';
import { connect } from 'dva';
import styles from './index.less';

import { Icon, Skeleton } from 'antd';
import { getComplianceRank } from '@/services/evaluate';

class ContentPage extends Component {
  constructor(props) {
    super(props);
  }
  state = {
    spiner: true,
    detailData: this.props.contentData || {},
  };

  componentDidMount() {
    const { dispatch, contentData } = this.props;
    if (contentData != {} || contentData.code === 0) {
      this.setState({
        spiner: false,
        detailData: contentData,
      });
    }
    // console.log('详情页数据1:', contentData);
  }

  componentWillReceiveProps(newProps) {
    this.setState({ detailData: newProps.contentData });
    // console.log('详情页数据2:', newProps.contentData);
  }

  close = () => {
    console.log('close');
    this.setState({ spiner: false });
  };

  render() {
    return (
      <div className={styles.contentBox}>
        <div className={styles.content}>
          <Skeleton
            loading={this.state.detailData.code != 0 ? true : false}
            style={{ height: '100%' }}
            active
          />
          {this.state.detailData && this.state.detailData.code == 0 && (
            <div>
              <p className={styles.detailTitle}>{this.state.detailData.data.title}</p>
              <p>
                <span style={{ marginRight: '15px' }}>来源：财富网</span>
                <span>发布时间：{this.state.detailData.data.published_time}</span>
              </p>
              <p dangerouslySetInnerHTML={{ __html: this.state.detailData.data.content }} />
            </div>
          )}
        </div>
      </div>
      // </div>
    );
  }
}

export default ContentPage;
